# -*- coding: utf-8 -*-
from qiniu import Auth, put_file
import qiniu.config
import glob2
import os
# 需要填写你的 Access Key 和 Secret Key
access_key = '4WheoeMSNdvV7VUagnE7Lk4S89B5lRWElC3S3FPb'
secret_key = '0L0l3OHxL4_uA6SbJtgyw1EyzLnZg09nhYDsZTd4'
# 构建鉴权对象
q = Auth(access_key, secret_key)
# 要上传的空间
bucket_name = 'lelouchxin'
resources = glob2.glob('dist/**')


def upload(path):
    file_name = path.replace('dist/', '')
    key = file_name
    token = q.upload_token(bucket_name, key, 3600)
    localfile = './' + path
    put_file(token, key, localfile)


for r in resources:
    if os.path.isfile(r):
        upload(r)
